import * as VueRouter from 'vue-router'
import isMobile from 'is-mobile'
const routes = [
	{ path: '/mobile', component: () => import('../mobile/home/index_mobile.vue') },
	{ path: '/computer', component: () => import('../pc/home/index_pc.vue') },
	{ path: '/ai-room', component: () => import('../mobile/home/ai_iframe.vue') },
	{ path: '/info-page', component: () => import('../comment/weInfo.vue'), meta: { hideFooter: true } },
	{ path: '/call-random', component: () => import('../comment/callRandom.vue') },
	{ path: '/comment-wall', component: () => import('../comment/commentWall.vue') },
];
const router = VueRouter.createRouter({
	// 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
	history: VueRouter.createWebHashHistory(),
	routes
});
router.beforeEach(async (to, _, next) => {
  const isHomepage = to.path === '/'; // 主页路径假设为'/'
  
  // 假设你有一个方法来检测是否为移动设备
  //const isMobile = useUserAgent().isMobile;

  if (isHomepage) {
    if (isMobile()) {
      // 如果是移动设备，跳转到移动版主页
      next('/mobile');
    } else {
      // 如果是PC，跳转到PC版主页
      next('/computer');
    }
  } else {
    // 其他路由正常处理
    next();
  }
});
export default router